package br.com.models;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.springframework.stereotype.Component;

@Component
@Entity
@Table(name="Users")
@Inheritance(strategy = InheritanceType.JOINED)
public class User {
	
	@Id 
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	@NotNull @Size(min=1,max=45)
	private String name;
	
	@NotNull @Size(min=5,max=80)
	private String email;
	
	@NotNull @Size(min=8,max=32)
	private String password;
	
	@NotNull
	private Character type;
	
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Address address;

	public User() {
		address = new Address();
	}
	
	public void inicializeAdress(String cep){
		address.InicializeAdress(cep);
	}
	
	public Address getAddress(){
		return address;
	}
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public Character getType() {
		return type;
	}
	public void setType(Character caracter) {
		this.type = caracter;
	}
	public String getStreet() {
		return address.getStreet();
	}
	public void setStreet(String street) {
		this.address.setStreet(street);
	}
	public Integer getHome_number() {
		return address.getHome_number();
	}
	public void setHome_number(Integer home_number) {
		this.address.setHome_number(home_number);
	}
	public String getNeighborhood() {
		return address.getNeighborhood();
	}
	public void setNeighborhood(String neighborhood) {
		this.address.setNeighborhood(neighborhood);
	}
	public String getComplement() {
		return address.getComplement();
	}
	public void setComplement(String complement) {
		this.address.setComplement(complement);
	}
	public String getCep() {
		return address.getCep();
	}
	public void setCep(String cep) {
		this.address.setCep(cep);
	}
	public String getCity() {
		return address.getCity();
	}
	public void setCity(String city) {
		this.address.setCity(city);
	}
	public String getState() {
		return address.getState();
	}
	public void setState(String state) {
		this.address.setState(state);
	}
	public String getCountry() {
		return address.getCountry();
	}
	public void setCountry(String country) {
		this.address.setCountry(country);
	}
}
